feat(mcp): add 'invoke' tool and update documentation - #3986
Conversation
- Introduced the 'invoke' tool to send test requests to running Function instances. - Updated instructions to include usage details for the 'invoke' tool, emphasizing the importance of absolute paths and providing guidance on parameters. - Added help resources for the 'invoke' command in the MCP server setup.
|
cc: @lkingland |
There was a problem hiding this comment.
Pull request overview
Adds an MCP invoke tool to the pkg/mcp server so agents can send test requests to a running Function (mirroring func invoke), plus a help resource and updated agent instructions to support a deploy-then-verify workflow.
Changes:
- Introduces
invokeas a new MCP tool backed byfunc invoke, with structured input/output and argument mapping. - Registers
invokein the MCP server and exposesfunc://help/invoke. - Updates MCP agent instructions to include
invokeguidance (notably post-deploy verification).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/mcp/tools_invoke.go | Implements the new invoke MCP tool and maps structured input to func invoke CLI flags. |
| pkg/mcp/tools_invoke_test.go | Adds unit tests validating argument passthrough, no-arg invocation behavior, and error surfacing. |
| pkg/mcp/mcp.go | Registers the invoke tool and adds the func://help/invoke resource. |
| pkg/mcp/instructions.md | Documents invoke usage and recommends deploy-then-invoke verification for agents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…safety - Updated the documentation to clarify that the 'path' parameter is now required for the invoke tool, ensuring users specify the function directory. - Added cautionary notes regarding potential side effects when invoking functions, especially in remote scenarios. - Enhanced test coverage for the invoke tool, including checks for missing 'path' arguments and readonly mode restrictions.
- Clarified the 'target' parameter description in the InvokeInput struct to specify that it defaults to auto-discovery, preferring local when both local and remote instances are available. This enhances user understanding of the parameter's behavior.
- Updated the invoke tool to support CloudEvent extension attributes, allowing users to pass key-value pairs as repeated '--extension key=value' flags. - Modified the documentation to reflect that the MCP server's read-only mode now also disables the invoke operation, alongside deploy and delete. - Enhanced test coverage for the invoke tool, ensuring proper handling of extensions and readonly mode restrictions.
lkingland
left a comment
There was a problem hiding this comment.
Very good!
I only found a few minor things (see below)
💯 Nice work so far
… documentation - Updated documentation to specify that invoking a Function is allowed in readonly mode, as it does not modify cluster state. - Removed the mention of invoking a Function from the list of disabled operations in readonly mode. - Enhanced the InvokeInput struct documentation to clarify default values for parameters and the requirement for absolute paths for file inputs. - Improved test coverage for the invoke tool to ensure correct behavior in readonly mode.
|
@lkingland I have done all the improvements as suggested |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Ankitsinghsisodya, lkingland The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
invokeMCP tool that lets agents send a test request to a local or remote running Function, mirroringfunc invoke(path, target, format, id, source, type, data, content-type, request-type, file, insecure, verbose)func://help/invokeMCP resource exposingfunc invoke --helpinvoketool in the MCP agent instructions, including the deploy-then-verify workflow (invoke a Function after deploying it to confirm it responds successfully before reporting success)/kind enhancement
Release Note
Docs